package com.qiandw.enterprise.credit.listener

import java.util.Date

import com.qiandw.enterprise.credit.service.BackstageUserSrv
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationListener
import org.springframework.stereotype.Service

/**
  * Created by Draven on 2018/7/13.
  * Email:hjx@qiandw.com
  */
@Service
class EnterpriseCreditEventListener extends ApplicationListener[BaseEvent] {

  @Autowired
  var backstageUserSrv: BackstageUserSrv = _

  override def onApplicationEvent(e: BaseEvent): Unit = {
    e match {
      case e: LoginEvent => {
        val user = e.user
        user.lastLoginTime = new Date
        backstageUserSrv.updateBackstageUser(user)
      }
    }
  }
}
